#ifndef __CORE_THREAD_H__
#define __CORE_THREAD_H__

#include <functional>
#include <string>
#include "core_semaphore.h"

class CoreThread
{
private:
	typedef std::function<void(CoreThread*)> ThreadCall;
	std::mutex mymutex;
	CoreSemaphore semaphore;
	bool isRuning;
	std::string threadname;

	ThreadCall onCreate;
	ThreadCall onRun;
	ThreadCall onDestory;
public:
	CoreThread();
	~CoreThread();

	void start(std::string threadName,ThreadCall onCreate = nullptr,ThreadCall onRun = nullptr,ThreadCall onDestory = nullptr);
	void stop();
	void exit();
	bool running();

private:
	void onWork();
};

#endif

